import config from "../utils/config"
export default {
	get: ({
		page,
		limit,
		query,
		cb
	}) => {
		uni.request({
			url: config["server"] + 'goods/query',
			method: "get",
			data: {
				page,
				limit,
				query: JSON.stringify(query)
			},
			success: cb,
		})
	},
	getOne: ({
		_id,
		success
	}) => {
		uni.request({
			url: config["server"] + 'goods/' + _id,
			method: "get",
			success,
		})
	},
	//更新商品出售状态
	update: ({
		_id,
		status,
		cb
	}) => {
		console.log('===============>', _id, status)
		uni.request({
			url: `${config["server"]}goods/update/${_id}`,
			data: {
				status
			},
			method: "PUT",
			success: (res) => {
				console.log('gods=============》', res)
				cb(res)
			},
		})
	},
	add:({goods,success})=>{
		uni.request({
			url:config["server"]+'goods',
			method:"post",
			data:goods,
			success,
		})
	}
}
